<?php
$f_id		= array('id'=>'f_id', 'style'=>'display:none;', 'name'=>'id', 'value'=> set_value('id',$id));
$f_fullname	= array('id'=>'f_fullname', 'class'=>'span6 form-control', 'name'=>'fullname', 'value'=> set_value('fullname',$fullname));
$f_address1	= array('id'=>'f_address1', 'class'=>'span12 form-control', 'name'=>'address1', 'value'=>set_value('address1',$address1));
$f_email	= array('id'=>'f_email', 'class'=>'span3 form-control', 'name'=>'email', 'value'=>set_value('email',$email));
$f_phone	= array('id'=>'f_phone', 'class'=>'span3 form-control', 'name'=>'phone', 'value'=> set_value('phone',$phone));
$f_company	= array('name'=>'company','class'=>'span3', 'value'=> set_value('company',$company));
?>
<?php echo form_open($this->config->item('admin_folder').'/customers/address_form/'.$customer_id.'/'.$id);?>

	<div class="row">
		<div class="span3">
			<label><?php echo lang('company');?></label>
			<?php echo form_input($f_company);?>
		</div>
	</div>
	<div class="row">
		<div class="span3">
			<label>Họ và tên</label>
			<?php echo form_input($f_fullname);?>
		</div>
	</div>
	<div class="row">
		<div class="span3">
			<label><?php echo lang('email');?></label>
			<?php echo form_input($f_email);?>
		</div>
		<div class="span3">
			<label><?php echo lang('phone');?></label>
			<?php echo form_input($f_phone);?>
		</div>
	</div>

	<div class="row">
		<div class="span6">
			<label> Tĩnh / TP</label>
			<?php echo form_dropdown('zone_id', $zones_menu, set_value('zone_id', $zone_id), 'id="f_zone_id" class="span12 form-control"');?>
		</div>
	</div>
    
  	<div class="row">
		<div class="span6">
			<label>Khu vực</label>
			<?php echo form_dropdown('area_id', $area_menu, set_value('area_id',!empty($area_id)?$area_id:""), 'id="f_area_id" class="span12 form-control"');?>
		</div>
	</div>
    
    

	<div class="row">
		<div class="span6">
			<label><?php echo lang('address');?></label>
			<?php echo form_input($f_address1);?>
		</div>
	</div>

	<div class="row">
		<div class="span6">
			<?php echo form_input($f_address2);?>
		</div>
	</div>


	<div class="form-actions">
		<input class="btn btn-primary" type="submit" value="<?php echo lang('save');?>"/>
	</div>
</form>
<script>
$('#f_zone_id').change(function(){
	$.post('<?php echo site_url('locations/get_zone_area');?>',{id:$(this).val()}, function(data) {
		$('#f_area_id').html("<option value=''> ---- Khu vực ---- </option>"+data);
	});
});
function save_address(){
	$.post("<?php echo site_url('secure/address_form');?>/"+$('#f_id').val(), {
																				fullname: $('#f_fullname').val(),
																				email: $('#f_email').val(),
																				phone: $('#f_phone').val(),
																				address1: $('#f_address1').val(),
																				address2: $('#f_address2').val(),
																				location_zone: $('#f_zone_id').val(),
																				zone_area: $('#f_area_id').val(),
																			  },
		function(){
			window.location = "<?php echo site_url('secure/my_account');?>";
		});
}
</script>